﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sy4_5
{
    public partial class Form1 : Form
    {
        int i = 0; // 控制蝴蝶图片切换的变量

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (timer1.Enabled == false)
            {
                timer1
.Enabled = true;
                button1
.Text = "停止";
            }
            else
            {
                timer1
.Enabled = false;
                button1
.Text = "开始";
                i
= 0;
                pictureBox1
.Image = Image.FromFile("bfly2.png"); // 回到初始状态
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (i % 2 == 0)
                pictureBox1
.Image = Image.FromFile("bfly1.png");
            else
                pictureBox1
.Image = Image.FromFile("bfly2.png");
            i
++;
        }
    }
}
